import re
text = """
<html><head><title>Title</title>
"""

soup = re.compile(r"<.*?>")
for item in soup.findall(text):
    print(item)
